<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *打卡记录
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$tabs=array(
	array('op'=>'list','title'=>'保单记录'),
);
if($_RQ['op']=='list'){
	$type=intval($_RQ['type']);
	$params=array('uniacid'=>$_SESSION['uniacid'],'merchid'=>$merchid);
	if(!empty($_RQ['baoid'])){
		$params['baoid']=intval($_RQ['baoid']);
		$return['params']['baoid']=intval($_RQ['baoid']);
	}
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	if(!empty($_RQ['name'])){
		$params['name like']='%'.trim($_RQ['name']).'%';
		$return['params']['name']=$_RQ['name'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_aihire_baodanlog',$params,array($pindex,$psize),$total,$fields,'','id desc');
	foreach($list as &$item){
		$item['baodan']=pdo_get('jy_aihire_job',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['baoid']));
		$item['jobtitle']=pdo_getcolumn('jy_aihire_job',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['jobid']),'title');
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'title','title'=>'保单方案','type'=>'string'),
			array('name'=>'baotype','title'=>'保单类型','type'=>'radio','options'=>'baotype'),
			array('name'=>'ordersn','title'=>'保单单号','type'=>'string'),
			array('name'=>'starttime','title'=>'保单起保时间','type'=>'time'),
			array('name'=>'endtime','title'=>'保单终止时间','type'=>'time'),
			array('name'=>'fee','title'=>'保单保费','type'=>'string'),
			array('name'=>'name','title'=>'被保人','type'=>'string'),
			array('name'=>'codesn','title'=>'身份证号','type'=>'string'),
			array('name'=>'jobtitle','title'=>'任务名称','type'=>'string'),
			array('name'=>'joblogid','title'=>'任务id','type'=>'string'),
			array('name'=>'createtime','title'=>'时间','type'=>'time'),
		)),
		'search'=>array(
			array('name'=>'title','width'=>15,'title'=>'保单方案','type'=>'string'),
			array('name'=>'name','width'=>15,'title'=>'被保人','type'=>'string'),
		)
	);
	$return['baotype']=$this->baotype;
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='del'){
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
	}else{
		$del=array();
	}
	if($_RQ['id']){
		$del[]=$_RQ['id'];
	}
	foreach($del as $id){
		$id=intval($id);
		if($id){
			pdo_delete('jy_aihire_baodanlog',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		}
	}
	exi('删除成功！');
}
